﻿using System;
using System.Collections.Generic;
using System.Text;
using taxi_sovereign.interfaces;

namespace taxi_sovereign.model
{
    [Serializable]
    class Cross:ICross
    {
        private IRoad[] Roads = new IRoad[0];
        private float x;
        private float y;
        bool chosen = false;

        public Cross(float Xx, float Yy)
        {
            x = Xx;
            y = Yy;
        }
        
#region ICross Members

        public IRoad[] GetRoads()
        {
            return Roads;
        }

        public void AddRoad(IRoad addroad)
        {
            Array.Resize(ref Roads, Roads.Length + 1);
            Roads[Roads.Length - 1] = addroad; 
        }

        public void DelRoad(IRoad delroad)
        {
            int k = 0;
            bool found = false;
            while((k < Roads.Length)&&(!found))
            {
                if (Roads[k] == delroad)
                {
                    found = true;
                }
                else
                {
                    k++;
                }

            }
            if (found)
            {
                Roads[k] = Roads[Roads.Length - 1];
                Array.Resize(ref Roads, Roads.Length - 1);
            }
        }

        public float GetPositionX()
        {
            return x;
        }

        public float GetPositionY()
        {
            return y;
        }

        public void SetPositionX(float inputx)
        {
            x = inputx;
        }

        public void SetPositionY(float inputy)
        {
            y = inputy;
        }

        #endregion



        #region ICross Members


        public bool Chosen
        {
            get
            {
                return chosen;
            }
            set
            {
                chosen = value;
            }
        }

        #endregion
    }
}
